﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ZFY.UnitOfWork.Interface
{
    public interface IZFYUnitOfWork: IDatabaseContextContainer,IDbContextTransactionContainer, IDisposable
    {
        Guid Id { get; }
       

        UnitOfWorkOption Options { get; }

        IZFYUnitOfWork Outer { get; }


        bool IsDisposed { get; }

        bool IsCompleted { get; }

        event EventHandler<UnitOfWorkFailedEventArgs> Failed;

        event EventHandler<UnitOfWorkEventArgs> Disposed;

        void SetOuter(IZFYUnitOfWork outer);

        void Initialize(UnitOfWorkOption options);

        Task SaveChangesAsync(CancellationToken cancellationToken = default);

        Task CompleteAsync(CancellationToken cancellationToken = default);

        Task RollbackAsync(CancellationToken cancellationToken = default);

        void OnCompleted(Func<Task> handler);
    }

}
